var ManageObj = function() {
	/* ��绱㈤�㈡�� */
	ManageObj.searchForm = null;

	/* �板���缂�杈���浣��㈡�� */
	ManageObj.operationFormPan = null;
    
    /* 涓�浼���浠�form */
	ManageObj.uploadForm = null ;
	
	/* �版����琛� */
	ManageObj.dataGridPan = null;

	/* DataStore */
	ManageObj.dataStore = null;
	
	/* Pic Store */
	ManageObj.picStore = null ;
	
	/* viewport */
	ManageObj.viewport = null;

	/* �板�绐��� */
	ManageObj.addWindow = null;

	/* 缂�杈�绐��� */
	ManageObj.updateWindow = null;
	
	/* �剧��绐��� */
	ManageObj.picWindow = null ;
 
    /* 涓�浼�绐��� */
	ManageObj.uploadWindow = null;

	/* �抽��浜�浠� */
	ManageObj.rightClick = null;

	/* �抽����涓�琛��� */
	ManageObj.rightMenuClickRow = null;
	
	/* ��淇��逛�������浠惰矾寰� */
	ManageObj.oldAttach = null;

	
ManageObj.suoshujingjuGuanLianStore = new Ext.data.JsonStore({
url : '/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do',
baseParams : {
flag : 'doGuanLian',
guanLianBiao : 'jingjuguanli',
guanLianZiDuan : 'jingjumingchen'
},
root : 'root',
totalProperty : 'totalProperty',
fields : ['jingjumingchen']
});

ManageObj.fenjulingdaoGuanLianStore = new Ext.data.JsonStore({
url : '/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do',
baseParams : {
flag : 'doGuanLian',
guanLianBiao : 'jingyuanxinxiguanli',
guanLianZiDuan : 'jingyuanmingchen'
},
root : 'root',
totalProperty : 'totalProperty',
fields : ['jingyuanmingchen']
});



	
	ManageObj.init();
}

/* ��濮����ㄦ�风���� */
ManageObj.init = function() {
	/* 蹇�椤昏���涓�杩�涓��ワ�����娌℃���ラ����绀轰俊�� */
	Ext.QuickTips.init();
	ManageObj.initSearchForm();
	ManageObj.initDataGridPan();
	ManageObj.loadData();
	ManageObj.initViewport();
}

/* ��濮�����绱㈣〃�� */
ManageObj.initSearchForm = function() {
	/* ��濮�����绱㈣〃�� */
	ManageObj.searchForm = new Ext.FormPanel( {
		id : 'mySearchForm',
		labelAlign : 'left',
		buttonAlign : 'center',
		bodyStyle : 'padding:0px;',
		frame : true,
		border : false,
		labelWidth : 95,
		items : [ {
			// xtype : 'fieldset',
			// title : '�ヨ�㈡�′欢',
			anchor : '100%',
			layout : 'column',   
			labelSeparator : '锛�',
			labelAlign : 'right',
			items : [  {
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'datefield',
format : 'Y-m-d',
fieldLabel : '��浣��堕��',
name : 'itimeStartSearch',
id : 'itimeStartSearch',
invalidText : '�ユ���煎�涓�姝ｇ‘锛�搴�涓�yyyy-mm-dd',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'datefield',
format : 'Y-m-d',
fieldLabel : '��',
name : 'itimeEndSearch',
id : 'itimeEndSearch',
invalidText : '�ユ���煎�涓�姝ｇ‘锛�搴�涓�yyyy-mm-dd',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '��灞���绉�',
name : 'fenjumingchenSearch',
id : 'fenjumingchenSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '��灞�璀�灞�',
name : 'suoshujingjuSearch',
id : 'suoshujingjuSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'datefield',
format : 'Y-m-d',
fieldLabel : '��绔��堕��',
name : 'chenglishijianSearch',
id : 'chenglishijianSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '��灞�棰�瀵�',
name : 'fenjulingdaoSearch',
id : 'fenjulingdaoSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '��绯荤�佃��',
name : 'lianxidianhuaSearch',
id : 'lianxidianhuaSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '璇�缁��板��',
name : 'xiangxidizhiSearch',
id : 'xiangxidizhiSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
{xtype : 'textfield',
fieldLabel : '��灞�璇���',
name : 'fenjuxiangqingSearch',
id : 'fenjuxiangqingSearch',
anchor : '100%'
} ]}
,
{
columnWidth : .2,
layout : 'form',
border : false,
items : [ 
 ]}
  ]
		} ],
		buttons : [ 
		
		{
			text : '�板�',
			hidden : ( ( R=="y" )? true:   (   ( BUTTON_PLACE == "0" )?  false : true )   )  ,
			handler : function() {
				ManageObj.doAdd();
			}
		},
		
		
		{
			text : '����',
			hidden : ( ( R=="y" )? true:   (   ( BUTTON_PLACE == "0" )?  false : true )   )  ,
			handler : function() {
				ManageObj.doDeleOrUnDele(null, 1);
			}
		},
		
		{
			text : '�ヨ��',
			handler : function() {
				ManageObj.doSearch();
			}
		}, {
			text : '娓�绌�',
			handler : function() {
				ManageObj.searchForm.getForm().reset();
			}
		} , {
			text : '瀵煎��Excel',
			hidden : ( ( R=="y" )? true:   (   ( BUTTON_PLACE == "0" )?  false : true )   )  ,
			xtype : 'button',
			handler : function() {
				ManageObj.doExportExcel();
			}
		}]
	});
}

/* ��濮����版����琛� */
ManageObj.initDataGridPan = function() {
	var sm = new Ext.grid.CheckboxSelectionModel();

	ManageObj.dataStore = new Ext.data.JsonStore( {
		root : 'root',
		totalProperty : 'totalProperty',
		remoteSort : true,
		fields : [ 'fenjumingchen','suoshujingju','chenglishijian','fenjulingdao','lianxidianhua','xiangxidizhi','fenjuxiangqing','id','itime','detail','deleteFlag','erjiguanlianzd','attr1','attr2','attr3','attr4','attr5','fuJian' ],
		proxy : new Ext.data.HttpProxy( {
			url : '/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do',
			method : 'POST'
		}),
		baseParams : {
			flag : 'getJsonStore',
			deleteFlagSearch : 0,
			r:R,
			erjiguanlianzd:erjiguanlianzd,
			sp:SP
		},
		listeners : {
			load :  function loadCallBack(store, records, options) {
				ManageObj.doTongJi();
			}
		}
	});
   
    /*
	pagingBar = new Ext.ux.MyPagingToolbar({
		pageSize : GLOBAL_MAX_PAGE_SIZE,
		store : ManageObj.dataStore,
		displayMsg : '褰���绗�{0}��{1}   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;��{2}�¤�板�',
		emptyMsg : "娌℃���惧�颁换浣�璁板�锛�",
		displayInfo : false
	});
	*/
	pagingBar = new Ext.PagingToolbar({
		pageSize : GLOBAL_MAX_PAGE_SIZE,
		store : ManageObj.dataStore,
		displayMsg : '褰���绗�{0}��{1}   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;��{2}�¤�板�',
		emptyMsg : "娌℃���惧�颁换浣�璁板�锛�",
		displayInfo : false
	});

	ManageObj.dataGridPan = new Ext.grid.GridPanel( {
		id : 'getTask',
		//title : '<font id="tongJiFont"></font>',
		store : ManageObj.dataStore,
		loadMask : true,
		bbar : pagingBar,
		columns : [ 
		  /*
		  sm,
		  */
		  /*
		  {
			header : "<font color='blue'>搴���</font>",
			width : 40,
			align : 'center',
			sortable : true,
			dataIndex : 'id'
		}
		*/
		{
header : '<font color="blue">��灞���绉�</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'fenjumingchen'
}, 
{
header : '<font color="blue">��灞�璀�灞�</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'suoshujingju'
}, 
{
header : '<font color="blue">��绔��堕��</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'chenglishijian'
}, 
{
header : '<font color="blue">��灞�棰�瀵�</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'fenjulingdao'
}, 
{
header : '<font color="blue">��绯荤�佃��</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'lianxidianhua'
}, 
{
header : '<font color="blue">璇�缁��板��</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'xiangxidizhi'
}, 
{
header : '<font color="blue">��灞�璇���</font>',
width : 60,
align : 'center',
sortable : true,
dataIndex : 'fenjuxiangqing'
}, 

	    {
			header : "<font color='blue'>��浣�</font>",
			width : 110,
			align : 'center',
			sortable : false,
			renderer : ManageObj.operatorRenderer,
			dataIndex : 'oper'
		} ],
		sm : sm,
		viewConfig : {
			forceFit : true,
			columnsText : '�剧ず��',
			sortAscText : '��搴�',
			sortDescText : '��搴�'
		},
		stripeRows : true,
		enableColumnHide:false,
		enableColumnMove : false ,
		columnLines:true,
		enableHdMenu:false,
		tbar : [ 
		
		{
			text : '�板��版��',
			hidden:  ( ( R=="y" )? true:    (   ( BUTTON_PLACE == "1" )? false  : true  )  ),
			handler : function() {
				ManageObj.doAdd();
			},
			icon : ADD_OPERATION_ICON_PATH
		},
		 
		
		{
			text : '���ゆ�版��',
			hidden:  ( ( R=="y" )? true:    (   ( BUTTON_PLACE == "1" )? false  : true  )  ),
			handler : function() {
				ManageObj.doDeleOrUnDele(null, 1);
			},
			icon : DELETE_OPERATION_ICON_PATH
		},
		
		{
			text : '瀵煎��Excel',
			hidden:  ( ( R=="y" )? true:    (   ( BUTTON_PLACE == "1" )? false  : true  )  ),
			xtype : 'button',
			handler : function() {
				ManageObj.doExportExcel();
			},
			icon : EXPORT_EXCEL_ICON_PATH
		},'->','<font id="tongJiFont"></font>'
		/*
		 {
			text : '�剧ず�ㄩ��',
			handler : function() {
				ManageObj.searchForm.getForm().reset();
				ManageObj.doSearch();
			},
			icon : DISPLAY_ALL_ICON_PATH
		},
		*/
		]

	});

	/* �抽��寮瑰�鸿���� */
	//ManageObj.dataGridPan.addListener('rowcontextmenu', ManageObj.rightClickFn);
}

/* �抽����搴�浜�浠� */
ManageObj.rightClickFn = function(grid, rowIndex, e) {
	e.preventDefault();
	ManageObj.rightMenuClickRow = rowIndex;

	/* 娓�绌烘��������椤� */
	if (ManageObj.rightClick != null) {
		ManageObj.rightClick.removeAll();
	}
	/* ��寤鸿���� */
	ManageObj.rightClick = new Ext.menu.Menu( {
		id : 'rightClickCont',
		items : [ {
			id : 'rMenu3',
			text : '�板�琛ㄥ��',
			icon : RIGHT_CLICK_ADD_OPERATION_ICON_PATH,
			handler : function() {
				ManageObj.doAdd();
			}
		}, {
			id : 'rMenu1',
			text : '娴�瑙�琛ㄥ��',
			icon : VIEW_OPERATION_ICON_PATH,
			handler : function() {
				ManageObj.update(ManageObj.rightMenuClickRow, "view");
			}
		}, {
			id : 'rMenu2',
			text : '缂�杈�琛ㄥ��',
			icon : EDIT_OPERATION_ICON_PATH,
			handler : function() {
				ManageObj.update(ManageObj.rightMenuClickRow, "update");
			}
		} ]
	});

	/* 褰�����涓�琛��舵�� */
	var nowSelectedRowStutas = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('deleteFlag');
	var nowSelectedRowId = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('id');
	var nowStutasStr = "���よ〃��";
	var nowIcon = LOCK_OPERATION_ICON_PATH;
	var nowOption = 1;
	/* �规��褰�����涓�琛����舵��锛��ㄦ���板����ゆ��瑙ｅ�昏����椤� */
	var menuItem = new Ext.menu.Item( {
		text : nowStutasStr,
		icon : nowIcon,
		handler : function() {
			ManageObj.doDeleOrUnDele(nowSelectedRowId, nowOption);
		}
	});
	ManageObj.rightClick.add(menuItem);
	ManageObj.rightClick.showAt(e.getXY());
}

/* ��濮���viewport */
ManageObj.initViewport = function() {
	ManageObj.viewport = new Ext.Viewport( {
		id : 'viewport',
		layout : 'border',
		border : false,
		frame : false,
		items : [ {
			id : 'west-panel',
			layout : 'fit',
			split : false,
			collapsible : true,
			collapsed : false,
			title : ' ',
			autoScroll : false,
			border : false,
			region : ( ( SEARCH_PLACE == "0" )?'north':'south' ),
			height : 170,
			items : [ ManageObj.searchForm ]
		}, {
			id : 'gridViewItem',
			layout : 'fit',
			split : false,
			border : false,
			autoScroll : false,
			region : 'center',
			items : [ ManageObj.dataGridPan ]
		} ]
	});
}

/* ��杞芥�版�� */
ManageObj.loadData = function() {
	ManageObj.dataStore.load( {
		params : {
			start : 0,
			limit : GLOBAL_MAX_PAGE_SIZE
		}
	});
}

/* ��浣���Renderer */
ManageObj.operatorRenderer = function(id, cellmeta, record, rowIndex,columnIndex, store) {
	var returnStr = "<a href=\"#\" onclick=\"ManageObj.update(" + rowIndex + ",'view');\">娴�瑙�</a>";
	if( R == "n" ){
		
	    returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.update(" + rowIndex + ",'update');\">缂�杈�</a>";
	    
	    
	    
		returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.doDeleOrUnDele('" + record.data['id'] + "','1');\">����</a>";
		
		
	    
		returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.doPic('update','"+record.data['id'] +"');\">�剧��</a>";
		
		
	    
		
		
	}else{
	    
	    
		
		returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.doPic('view','"+record.data['id'] +"');\">�剧��</a>";
		
		
	}
	
	if( SP == "y" ){
		returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.doShenPi('" + record.data['id'] + "','瀹℃�归��杩�');\">瀹℃�归��杩�</a>";
		returnStr += "&nbsp;|&nbsp;<a href=\"#\" onclick=\"ManageObj.doShenPi('" + record.data['id'] + "','瀹℃�归┏��');\">瀹℃�归┏��</a>";
	}
	return returnStr;
}

ManageObj.doShenPi = function( id , shenpi ) {
	Ext.MessageBox.confirm('娓╅Θ����锛�', '纭�璁ら��瑕���浜よ�板���锛�',
		 function(info) {
			if (info == "yes") {
				Ext.Ajax.request( {
					waitMsg : '�版����浜や腑......',
					url : '/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do',
					method : 'POST',
					success : function(response, options) {
						var responseArray = Ext.util.JSON.decode(response.responseText);
						Ext.MessageBox.show( {
							title : '娓╅Θ����锛�',
							msg : responseArray.msg,
							buttons : Ext.MessageBox.OK,
							fn : function() {
								ManageObj.dataStore.reload();
							},
							icon : Ext.MessageBox.INFO
						});
					},
					failure : function(response, options) {
						Ext.MessageBox.alert('娓╅Θ����锛�', responseArray.msg);
					},
					params : {
						flag : "doShenPi",
						id : id,
						shenpi : shenpi
					}
				});
			}
		});
}

/* �ヨ�� */
ManageObj.doSearch = function() {
	//杈��ラ」��娉��х���ゆ��
	var itimeStartSearch = document.all.itimeStartSearch.value;
	var itimeEndSearch = document.all.itimeEndSearch.value;
	
	if( itimeStartSearch != "" && itimeEndSearch != "" ){
		if( itimeStartSearch > itimeEndSearch ){
			Ext.MessageBox.alert( WARRING_WIN_TITLE , "��浣�寮�濮��堕�翠��藉ぇ浜���浣�缁����堕�达�");
			return;
		}
	}
	
	ManageObj.dataStore.baseParams.fenjumingchenSearch = document.all.fenjumingchenSearch.value; 
ManageObj.dataStore.baseParams.suoshujingjuSearch = document.all.suoshujingjuSearch.value; 
ManageObj.dataStore.baseParams.chenglishijianSearch = document.all.chenglishijianSearch.value; 
ManageObj.dataStore.baseParams.fenjulingdaoSearch = document.all.fenjulingdaoSearch.value; 
ManageObj.dataStore.baseParams.lianxidianhuaSearch = document.all.lianxidianhuaSearch.value; 
ManageObj.dataStore.baseParams.xiangxidizhiSearch = document.all.xiangxidizhiSearch.value; 
ManageObj.dataStore.baseParams.fenjuxiangqingSearch = document.all.fenjuxiangqingSearch.value; 

	ManageObj.dataStore.baseParams.itimeStartSearch = itimeStartSearch;
	ManageObj.dataStore.baseParams.itimeEndSearch = itimeEndSearch;


	ManageObj.dataStore.load( {
		params : {
			start : 0,
			limit : GLOBAL_MAX_PAGE_SIZE
		}
	});
	
}

/* 寰��版坊����缂�杈���FormPanel */
ManageObj.getOperationFormPan = function(rowIndex, flag) {
	ManageObj.operationFormPan = new Ext.FormPanel( {
		id : 'operationFormPan',
		labelAlign : 'left',
		buttonAlign : 'center',
		bodyStyle : 'padding:0px;',
		frame : true,
		border : true,
		labelWidth : 110,
		autoWidth : true,
		autoHeight : true,
		fileUpload : true, 
		items : [ {
			anchor : '100%',
			layout : 'column',
			labelSeparator : '锛�',
			labelAlign : 'right',
			items : [ {
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'textfield',
fieldLabel : '<font color="red">*</font>&nbsp;&nbsp;��灞���绉�',
name : 'fenjumingchen',
id : 'fenjumingchen',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'combo',
fieldLabel : '<font color="red">*</font>&nbsp;��灞�璀�灞�',
store : ManageObj.suoshujingjuGuanLianStore,
valueField : 'jingjumingchen',
displayField : 'jingjumingchen',
mode : 'remote',
forceSelection : false,
hiddenName : 'suoshujingjuHidd',
triggerAction : 'all',
editable : true,
name : 'suoshujingju',
id : 'suoshujingju',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'datefield',
format : 'Y-m-d',
fieldLabel : '<font color="red">*</font>&nbsp;&nbsp;��绔��堕��',
name : 'chenglishijian',
id : 'chenglishijian',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'combo',
fieldLabel : '<font color="red">*</font>&nbsp;��灞�棰�瀵�',
store : ManageObj.fenjulingdaoGuanLianStore,
valueField : 'jingyuanmingchen',
displayField : 'jingyuanmingchen',
mode : 'remote',
forceSelection : false,
hiddenName : 'fenjulingdaoHidd',
triggerAction : 'all',
editable : true,
name : 'fenjulingdao',
id : 'fenjulingdao',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'textfield',
fieldLabel : '<font color="red">*</font>&nbsp;&nbsp;��绯荤�佃��',
name : 'lianxidianhua',
id : 'lianxidianhua',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'textfield',
fieldLabel : '<font color="red">*</font>&nbsp;&nbsp;璇�缁��板��',
name : 'xiangxidizhi',
id : 'xiangxidizhi',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : 'textarea',
fieldLabel : '<font color="red">*</font>&nbsp;&nbsp;��灞�璇���',
name : 'fenjuxiangqing',
id : 'fenjuxiangqing',
anchor : '95%',
allowBlank : false
}]} 
,{
columnWidth : 1,
layout : 'form',
border : false,
items : [ {
xtype : (flag == 'view') ? 'label' : 'fileuploadfield',
style : (flag == 'view') ? 'margin-left:0px;padding-top:3px;padding-bottom:3px;' : 'margin-left:0px;',
fieldLabel : (flag == 'view') ? '' : '��浠�',
name : 'fuJian',
id : 'fuJian',
anchor : '95%',
buttonText : '娴�瑙�'
}]} 
,{
				columnWidth : 1,
				layout : 'form',
				border : false,
				items : [ {
					xtype : 'textarea',
					fieldLabel : '澶�娉�',
					name : 'detail',
					id : 'detail',
					anchor : '95%'
				} ]
			} ]
		} ]
	});

	/* 娴�瑙���缂�杈��舵��褰�����涓�琛��峰���帮�寰��板���琛�璁板���淇℃��锛���濮���杈��ラ」 */
	if (rowIndex != null) {
		ManageObj.operationFormPan.findById('fenjumingchen').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('fenjumingchen');
ManageObj.operationFormPan.findById('suoshujingju').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('suoshujingju');
ManageObj.operationFormPan.findById('chenglishijian').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('chenglishijian');
ManageObj.operationFormPan.findById('fenjulingdao').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('fenjulingdao');
ManageObj.operationFormPan.findById('lianxidianhua').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('lianxidianhua');
ManageObj.operationFormPan.findById('xiangxidizhi').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('xiangxidizhi');
ManageObj.operationFormPan.findById('fenjuxiangqing').value = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('fenjuxiangqing');
var attachVal = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('fuJian');
if (flag == 'view') {
var fileName = attachVal.substring(attachVal.lastIndexOf("/") + 1);
ManageObj.operationFormPan.findById('fuJian').html = "<a style='padding-left:0px;margin-left:4px;' href=" + attachVal + ">" + fileName + "</a>";
} else {
ManageObj.operationFormPan.findById('fuJian').value = attachVal;
}
ManageObj.oldAttach = ManageObj.dataGridPan.getStore().getAt(rowIndex).get('fuJian');
		Ext.getCmp('detail').setValue( ManageObj.dataGridPan.getStore().getAt(rowIndex).get( 'detail'));
	}

	return ManageObj.operationFormPan;
}

/**
 * @param {}  Id
 * @param {} deleteFlag (1:���� 锛� 0:瑙ｅ��)
 * @function ���ゆ��瑙ｅ��
 */
ManageObj.doDeleOrUnDele = function(id, deleteFlag) {
	if (!id) {
		ManageObj.doCheck(deleteFlag);
	} else {
		var infoTmp = (deleteFlag == "0") ? "" : "����";
		Ext.MessageBox.confirm('娓╅Θ����锛�', '纭�璁ら��瑕�' + infoTmp + '����璁板���锛�',
		 function(info) {
			if (info == "yes") {
				Ext.Ajax.request( {
					waitMsg : '�版����浜や腑......',
					url : '/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do',
					method : 'POST',
					success : function(response, options) {
						var responseArray = Ext.util.JSON.decode(response.responseText);
						Ext.MessageBox.show( {
							title : '娓╅Θ����锛�',
							msg : responseArray.msg,
							buttons : Ext.MessageBox.OK,
							fn : function() {
								ManageObj.dataStore.reload();
							},
							icon : Ext.MessageBox.INFO
						});
					},
					failure : function(response, options) {
						Ext.MessageBox.alert('娓╅Θ����锛�', responseArray.msg);
					},
					params : {
						flag : "doDeleOrUnDele",
						id : id,
						deleteFlag : deleteFlag
					}
				});
			}
		});
	}
}

/**
 * @param {} deleOrUnDele 锛�1锛����� 锛� 0锛�瑙ｅ�伙�
 * @function ��浜ゅ���ゆ��瑙ｅ�绘�舵�版����娉��ч��璇�
 */
ManageObj.doCheck = function(deleOrUnDele) {
	var sm = ManageObj.dataGridPan.getSelectionModel();
	var sel = sm.getSelections();
	var selCount = sm.getCount();
	if (selCount == 0) {
		Ext.Msg.show( {
			title : '娓╅Θ��绀猴�',
			buttons : Ext.MessageBox.OK,
			msg : '娌℃����浠ユ��浜ょ���版��锛�璇烽���╋�',
			icon : Ext.MessageBox.ERROR
		});
		return;
	}

	/* ��涓�涓���浠ユ��浜ょ��璁板� */
	var selectedRowId = "";
	/* ��涓���涓�涓哄凡���ょ�舵����璁板� */
	var hasDeletedRowId = "";
	/* ��涓���涓�涓哄凡瑙ｅ�荤�舵����璁板� */
	var hasUnDeletedRowId = "";
	for ( var i = 0; i < selCount; i++) {
		var deleteFlag = sel[i].data["deleteFlag"];
		if (deleOrUnDele == "1") {
			if (deleteFlag == "1") {
				hasDeletedRowId += (hasDeletedRowId == "") ? (i + 1 + "") : ","+ (i + 1);
			} else {
				selectedRowId += (selectedRowId == "") ? (sel[i].data["id"]) : "," + (sel[i].data["id"]);
			}
		} else if (deleOrUnDele == "0") {
			if (deleteFlag == "0") {
				hasUnDeletedRowId += (hasUnDeletedRowId == "") ? (i + 1 + "") : "," + (i + 1);
			} else {
				selectedRowId += (selectedRowId == "") ? (sel[i].data["id"] + "") : "," + (sel[i].data["id"]);
			}
		}
	}

	if (hasUnDeletedRowId != "") {
		Ext.Msg.show( {
			title : '娓╅Θ��绀猴�',
			buttons : Ext.MessageBox.OK,
			msg : '�ㄩ���╃��绗�' + hasUnDeletedRowId + "琛����版��宸茬�涓烘�ｅ父�舵��锛�璇烽���伴���╋�",
			icon : Ext.MessageBox.ERROR
		});
		return;
	} else if (hasDeletedRowId != "") {
		Ext.Msg.show( {
			title : '娓╅Θ��绀猴�',
			buttons : Ext.MessageBox.OK,
			msg : '�ㄩ���╃��绗�' + hasDeletedRowId + "琛����版��宸茬�琚����わ�璇烽���伴���╋�",
			icon : Ext.MessageBox.ERROR
		});
		return;
	}

	ManageObj.doDeleOrUnDele(selectedRowId, deleOrUnDele);
};

/* 瀵煎��Excel */
ManageObj.doExportExcel = function() {
	var url = "/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do?flag=doExportExcel";
	window.open(  url );
};

/* 瀛�娈电�璁� */
ManageObj.doTongJi = function(){
	Ext.Ajax.request({
         url :'/WEB-ROOT/app/jingjujifenjuguanli/fenjuguanli.do' ,
         method:'POST',
         success : function(response, options) {
        	   var responseArray = Ext.util.JSON.decode(response.responseText);
        	   document.all.tongJiFont.innerHTML = responseArray.msg ;
        },
        params : {
              flag : "doTongJi",
              m : M,
              r:R,
              erjiguanlianzd:erjiguanlianzd
        }
    }); 
}; 


